home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
038a
/
bas_int1.zip
/
_ISFILE.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-06-02
|
1KB
|
41 lines
'==================================================================
' Quick Basic Forum
' Date : 28-May-91
' From : Rick Cooper
'Subject : File handling (Open error)
' Uses CALL INTERRUPT; be sure to INCLUDE 'QB.BI'
' and use appropriate libraries containing
' CALL INTERRUPT
'=================================================================
'sample main program code using FUNCTION FileExist%
DECLARE FUNCTION FileExist% (FileName$)
'$INCLUDE: 'Qb.bi'
FileName$ = "ANYFILE.INP"
InFile% = FREEFILE
IF FileExist%(FileName$) THEN
OPEN FileName$ For INPUT AS #InFile%
ELSE
WhatEverYouWant
END IF
'Here's the FUNCTION
FUNCTION FileExist% (FileName$)
DIM InRegsX AS RegTypeX, OutRegsX AS RegTypeX 'Dim The Registers
FileToSet$ = FileName$ + CHR$(0) 'We Use The Fast Small
InRegsX.ax = (256 * &H43) + &H0 'Get File Attribute
InRegsX.ds = VARSEG(FileToSet$) 'Function. If Carry Flag
InRegsX.dx = SADD(FileToSet$) 'Is Set Error Otherwise
CALL INTERRUPTX(&H21, InRegsX, OutRegsX) 'File And Drive/Path Valid
IF (OutRegsX.flags AND 1) <> 0 THEN
FileExist% = 0 'If Error File Doesn't Exist
ELSE
FileExist% = 1 'OtherWise Set To Non Zero
END IF
END FUNCTION